package com.codebase.zookeeper.zk;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;
import org.junit.Test;

/**
 * @describe:
 * @author:houkai@lykj.com
 * @Date: 2018/6/2 16:01
 * @version 1.0
 */
public class Auth {

    /**
     * 使用包含权限会话信息的zk创建数据节点
     */
    @Test
    public void test() throws Exception{
        String path = "/root_auth";
        ZooKeeper zk = new ZooKeeper("127.0.0.1:2181", 5000, null);
        zk.addAuthInfo(path, "user:pass".getBytes());
        zk.create(path, "111".getBytes(), ZooDefs.Ids.CREATOR_ALL_ACL, CreateMode.EPHEMERAL);
        Thread.sleep(3000);
    }

    

}
